package top.lishuoboy.knife4j.swagger3_0_0.vo;

import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import lombok.experimental.SuperBuilder;
import top.lishuoboy.knife4j.swagger3_0_0.enums.Code;

import javax.validation.constraints.NotBlank;

/** 响应数据 */
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@JsonPropertyOrder({"code", "msg", "data"})
@ApiModel("响应数据")
public class RespVo<T> {
    /** 响应状态码（0：成功，其他：失败） */
    @ApiModelProperty(value = "响应码（0：成功，其他：失败）", required = true)
    @NotBlank
    private Integer code;
    /** 响应消息（对响应码的补充说明） */
    @ApiModelProperty(value = "响应消息（对响应码的补充说明）")
    private String msg;
    /** 响应数据 */
    @ApiModelProperty(value = "响应数据")
    private T data;

    public RespVo(Code code) {
        this.code = code.code;
        this.msg = code.msg;
    }

    public RespVo(Code code, T data) {
        this.code = code.code;
        this.msg = code.msg;
        this.data = data;
    }
}
